package com.zrkizzy.seckill.service.tool.impl;

import com.zrkizzy.seckill.service.tool.IMessageProducerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * RabbitMQ生产者操作接口实现类
 *
 * @author zhangrongkang
 * @since 2023/4/8
 */
@Service
@Slf4j
public class MessageProducerServiceImpl implements IMessageProducerService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * RabbitMQ发送消息
     *
     * @param exchange 交换机
     * @param routingKey 路由
     * @param message 消息数据
     */
    @Override
    public void convertAndSend(String exchange, String routingKey, String message) {
        rabbitTemplate.convertAndSend(exchange, routingKey, message);
    }
}
